package cn.bugstack.domain.activity.service.discount;


import cn.bugstack.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Slf4j
@Service("ZK")
public class ZKCalculateService extends AbstractDiscountCalculateService {


    @Override
    protected BigDecimal doCalculate(BigDecimal originalPrice, GroupBuyActivityDiscountVO.GroupBuyDisCount groupBuyDisCount) {
        String marketExpr = groupBuyDisCount.getMarketExpr();

        BigDecimal multiplyPrice = originalPrice.multiply(new BigDecimal(marketExpr));
        if (multiplyPrice.compareTo(BigDecimal.ZERO) <= 0) {
            return new BigDecimal("0.01");
        }
        return multiplyPrice;
    }


}
